package cn.uniqueww.javadesignpatterns.demos.design.fstGroup;

import org.springframework.stereotype.Component;

import java.util.concurrent.ConcurrentHashMap;

@Component
public class UserComputedAmountFactory {

    public static ConcurrentHashMap<UserType,ComputedAmount> discountMap = new ConcurrentHashMap<>();

    public static ComputedAmount getComputedAmount(UserType userType) {
        return discountMap.get(userType);
    }

    public static void register(UserType userType, ComputedAmount computedAmount) {
        discountMap.put(userType, computedAmount);
    }
}
